/**
 * Created with Vim7.3 Mac
 * @fileOverview : 
 * @author : Lyle lylechen2014@gmail.com
 * @since : 2016-08-04 10:56:02
 * @filename : src/components/setting.js
 * @version : 
 * @description : 
 */

import React, { Component } from 'react';
import {
    StyleSheet,
    Text,
    View,
    Alert
} from 'react-native';

import Index from './index';
import Help from './help';
import Feedback from './feedback';

class Setting extends Component {

    constructor(props) {
        super(props);
        this.state = {};
    }

    render() {
        return (
            <View style={styles.container}>
                <View style={styles.line}>
                    <Text suppressHighlighting={true} style={styles.lineText}> Account Settings </Text>
                </View>
                <View style={styles.line} >
                    <Text suppressHighlighting={true} style={styles.lineText} onPress={() => this.gotoHelp()}> Help / FAQ </Text>
                </View>
                <View style={styles.line}>
                    <Text suppressHighlighting={true} style={styles.lineText} onPress={ () => this.gotoFeedback() }> Feedback </Text>
                </View>
                <View style={styles.line}>
                    <Text suppressHighlighting={true} style={styles.lineText} onPress={() => this.logOut()}> Log Out </Text>
                </View>
                <View>
                   <Text style={styles.version}> © 2002 - 2016  PositiveSingles.com, V0.0.1  </Text>
                </View>
            </View>
        );
    }

    logOut() {
        Alert.alert(
            'Title',
            'Are you sure you want to log out?',
            [
              {text: 'Cancel', onPress: () => console.log('OK Cancel!')},
              {text: 'OK', onPress: () => this.doOut()},
            ]
          )
    }

    doOut() {
        let tthis = this;
        Share.fetchMain({
            url: 'logout',
            callback: function () {
                Share.loginOut();
                Utils.navResetTo(tthis.props.navigator, {
                    name: 'Index',
                    component: Index,
                })
            }
        })
    }

    gotoHelp() {
        Utils.navJumpTo(this.props.navigator, {
            name: "Help",
            component: Help,
            title: 'Help / FAQ'
        });  
    }

    gotoFeedback() {
        Utils.navJumpTo(this.props.navigator, {
            name: "Feedback",
            component: Feedback,
            title: 'Feedback'
        });  
    }

}

const styles = StyleSheet.create(Css.SettingStyle);

export default Setting;


